package com.braveman.im.ui.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.braveman.im.R;
import com.braveman.im.bean.ChildBean;
import com.braveman.im.bean.GroupBean;
import com.braveman.im.bean.ZhengQiChengXinPlatformBean;
import com.braveman.im.manager.ApiManager;
import com.braveman.im.ui.adapter.MyAdapter;
import com.braveman.im.utils.UtilsStyle;
import com.ht.baselibs.retrofit.NetCallBack;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.ui.widget.TitleBarView;
import com.ht.baselibs.utils.ActivityUtils;
import com.vondear.rxtools.RxBarTool;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/10/17.
 */

/**
 * 我创建的平台和我加入的平台
 */
public class IntegrityActivity extends BaseActivity {
    //    private ExpandableListView expandableListView;
//    private MyAdapter adapter;
//    private List<GroupBean> list;
//    private RelativeLayout mRlNeedShow;
    private ImageView ivItemHeadIcon;
    private TextView tvItemName;
    private String id;
    private ZhengQiChengXinPlatformBean zhengQiChengXinPlatformBean;

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("我的平台").addActions(new TitleBarView.Action(R.mipmap.personal_card_detail_title_icon_add) {
            @Override
            public void performAction(View view) {
                //跳转新建平台页面
            }
        }).setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.finishActivity(IntegrityActivity.this);
            }
        });
    }

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected int initContentView() {
        UtilsStyle.setStatusBarMode(this, true);
        RxBarTool.FlymeSetStatusBarLightMode(getWindow(), true);
        RxBarTool.MIUISetStatusBarLightMode(getWindow(), true);
        return R.layout.activity_integrity;
    }

    @Override
    protected void initIntentData(Intent callIntent) {
        id = callIntent.getStringExtra("id");
    }

    @Override
    protected void initChildView() {
//        expandableListView = (ExpandableListView) findViewById(R.id.my_listview);
//        mRlNeedShow = (RelativeLayout) findViewById(R.id.rl_need_show);

        ivItemHeadIcon = (ImageView) findViewById(R.id.iv_item_head_icon);
        tvItemName = (TextView) findViewById(R.id.tv_item_name);

    }

    @Override
    protected void initChildData() {
        zhengQiChengXinPlatformBean = new ZhengQiChengXinPlatformBean();
        ApiManager.getApi().zqcxPlatform().enqueue(new NetCallBack<ZhengQiChengXinPlatformBean>() {
            @Override
            protected void onSuccess(Call<ZhengQiChengXinPlatformBean> call, Response<ZhengQiChengXinPlatformBean> response) {
                zhengQiChengXinPlatformBean = response.body();
                if (response != null) {
                    tvItemName.setText(zhengQiChengXinPlatformBean.joinedCategory.name);

                }
            }
        });

//        list = new ArrayList<GroupBean>();
//        {
//            //第一级子项
//            List<ChildBean> list1 = new ArrayList<>();
//            ChildBean cb1 = new ChildBean("11", "正气诚信平台", "诚信星级★★★★", "科技 农业 旅游", null, null);
//            ChildBean cb2 = new ChildBean("11", "正气诚信平台", "诚信星级★★★★", "科技 农业 旅游", null, null);
//            ChildBean cb3 = new ChildBean("11", "正气诚信平台", "诚信星级★★★★", "科技 农业 旅游", null, null);
//            ChildBean cb4 = new ChildBean("11", "正气诚信平台", "诚信星级★★★★", "科技 农业 旅游", null, null);
//
//
//            //第二级子项
//            List<ChildBean> list2 = new ArrayList<>();
//            ChildBean cb5 = new ChildBean("11", "正气诚信读书会平台", "诚信星级★★", "读书  IT   吃客", null, null);
//            ChildBean cb6 = new ChildBean("11", "正气诚信读书会平台", "诚信星级★★", "读书  IT   吃客", null, null);
//            ChildBean cb7 = new ChildBean("11", "正气诚信读书会平台", "诚信星级★★", "读书  IT   吃客", null, null);
//            ChildBean cb8 = new ChildBean("11", "正气诚信读书会平台", "诚信星级★★", "读书  IT   吃客", null, null);
//            list1.add(cb1);
//            list1.add(cb2);
//            list1.add(cb3);
//            list1.add(cb4);
//            list2.add(cb5);
//            list2.add(cb6);
//            list2.add(cb7);
//            list2.add(cb8);
//
//            GroupBean gb1 = new GroupBean("我创建的平台", list1);
//            GroupBean gb2 = new GroupBean("我加入的平台", list2);
//            list.add(gb1);
//            list.add(gb2);
//        }
//
//        adapter = new MyAdapter(list, this);
//        expandableListView.setAdapter(adapter);
//        expandableListView.setGroupIndicator(null);
//        expandableListView.collapseGroup(0);
//        //ex控件点击事件
//        expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
//            @Override
//            public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
//                if (expandableListView.isGroupExpanded(i)) {
//                    mRlNeedShow.setVisibility(View.VISIBLE);
//                    expandableListView.collapseGroup(i);
//                } else {
//                    mRlNeedShow.setVisibility(View.GONE);
//                    expandableListView.isGroupExpanded(i);
//                }
//                return false;
//            }
//        });

    }

    @Override
    protected void setChildViewListener() {

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);


        switch (v.getId()) {

        }
    }
}
